﻿
Pages_Report_ReportGeneral = new function () {
    this.ObjSearch = {      
        FromDate: '1/1/2012',
        ToDate:'1/1/2030'
    };
    

    this.getOptionSearch = function() {
        this.ObjSearch.FromDate = $("#txtFromDate").val();
        this.ObjSearch.ToDate = $("#txtToDate").val();
    };
    this.documentReady = function () {
        this.getOptionSearch();
        this.bindData();
    };

    this.bindData = function () {
        Loading.showProcess();        
        $.ajax({
            type: "GET",
            url: "/handler/HandlerReport.ashx",
            data: {                
                fromDate: this.ObjSearch.FromDate, toDate:this.ObjSearch.ToDate, t: "rptGeneral"
            },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: false,
            success: function (data) {
                Pages_Report_ReportGeneral.processData(data);
                Loading.closeProcess();
            }
        });

    };

    this.processData = function (data) {
        $("#tdTotalVNDIn").html(COMMON.formatMoney(data.In.TotalVndIn));
        $("#tdTotalAuIn").html(COMMON.formatMoney(data.In.TotalReceiveAu));
        $("#tdTotalAgIn").html(COMMON.formatMoney(data.In.TotalReceiveAg));
        
        $("#tdTotalAuPlay").html(COMMON.formatMoney(data.Ses.TotalAuBet));
        $("#tdTotalAgPlay").html(COMMON.formatMoney(data.Ses.TotalAgBet));
        $("#tdTotalAuBonus").html(COMMON.formatMoney(data.Ses.TotalAuCurrent));
        $("#tdTotalAgBonus").html(COMMON.formatMoney(data.Ses.TotalAgCurrent));
        $("#tdTotalAgToAu").html(COMMON.formatMoney(data.Convert.FromAg));
        $("#tdTotalAuFromAg").html(COMMON.formatMoney(data.Convert.ToAu));
        
        $("#tdTotalAuOut").html(COMMON.formatMoney(data.Out.TotalAuOut));
        $("#tdTotalVNDOut").html(COMMON.formatMoney(data.Out.TotalVndOut));
        
        
    };
   
    $("#btnSearch").live('click', function () {
        Pages_Report_ReportGeneral.documentReady();
        
    });
   
}